#!/usr/bin/env bash
projectName=dola

java_pid=`ps aux | grep java | grep service | grep -i $projectName |grep -v grep |  awk '{print $2}'`
kill -9 $java_pid

sleep 3

echo "begin to start java"

be_runtime=/runtime/$projectName/service/be

#资源路径
resource_home=$be_runtime/resource

log_home=$be_runtime/log
ossDownloadDir=/opt/oss

if [ ! -d $log_home ]; then
    mkdir -p $log_home
fi

if [ ! -d $ossDownloadDir ]; then
    mkdir $ossDownloadDir
fi

if [ ! -d /opt/tmp ];then
  mkdir /opt/tmp
fi

if [ ! -d /opt/files/ ];then
  mkdir /opt/files/
fi

fanglangHostname=`hostname`

cd $be_runtime
if [ $fanglangHostname = "chenj-mongo" ]; then
    nohup java -DnodeType=service  -Dfile.encoding=UTF-8 -Dsingle.node=true -jar $projectName-0.0.1-SNAPSHOT.jar > $log_home/spring.log 2>&1 &
else
    nohup java -DnodeType=service   -Dfile.encoding=UTF-8 -jar $projectName-0.0.1-SNAPSHOT.jar > $log_home/spring.log 2>&1 &
fi

echo "start java success"